package com.limanyik.family.oss.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.limanyik.family.common.entity.BasisAlibabaOssFile;
import com.limanyik.family.common.enums.BaseDeleteStatusEnum;
import com.limanyik.family.oss.mapper.BasisAlibabaOssFileMapper;
import com.limanyik.family.oss.service.BasisAlibabaOssFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.UUID;

/**
 * <p>
 * 系统-OSS阿里云服务文件表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-11-24
 */
@Service
public class BasisAlibabaOssFileServiceImpl extends ServiceImpl<BasisAlibabaOssFileMapper, BasisAlibabaOssFile> implements BasisAlibabaOssFileService {

    @Autowired
    BasisAlibabaOssFileMapper basisAlibabaOssFileMapper;

    @Override
    public boolean save(BasisAlibabaOssFile basisAlibabaOssFile) {
        basisAlibabaOssFile.setId(UUID.randomUUID().toString().replace("-", ""));
        basisAlibabaOssFile.setCreateTime(LocalDateTime.now());
        basisAlibabaOssFile.setUpdateTime(LocalDateTime.now());
        basisAlibabaOssFile.setDeleteStatus(BaseDeleteStatusEnum.NORMAL.getCode());
        basisAlibabaOssFile.setVersion(0);
        return basisAlibabaOssFileMapper.insert(basisAlibabaOssFile) > 0;
    }
}
